import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_base_widget/utils/SPUtil.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:convert' as convert;

//导包
// import 'package:flutter/services.dart' show rootBundle;

/// 创建人： Created by zhaolong
/// 创建时间：Created by  on 2020/9/25.
///
/// 创建人： Created by zhaolong
/// 创建时间：Created by  on 2020/9/25.
///
/// gongzhonghao biglead
/// github https://github.com/zhaolongs
/// bili https://space.bilibili.com/513480210
/// zhihu https://www.zhihu.com/people/zhao-long-90-89
/// csdn https://blog.csdn.net/zl18603543572
/// 西瓜视频 https://www.ixigua.com/home/3662978423
///
///

void main() {
  ///启动根目录
  runApp(MaterialApp(
    home: Example1004(),
  ));
}

class Example1004 extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _ExampleState();
  }
}

class _ExampleState extends State {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    SPUtil.init();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(" File "),
      ),
      backgroundColor: Colors.grey,
      body: Container(
        width: MediaQuery.of(context).size.width,
        color: Colors.white,
        //关键代码
        child: Column(
          children: [
            TextButton(
              child: const Text("保存基本数据"),
              onPressed: () {
                SPUtil.save("testString", "张三");
                SPUtil.save("testInt", 33);
                SPUtil.save("是否生病了", false);
              },
            ),
            TextButton(
              child: const Text("获取基本数据"),
              onPressed: () {
                bool isBool = SPUtil.getBool("是否生病了");
                String userName = SPUtil.getString("testString");
              },
            ),
            TextButton(
              child: Text("getThemPath"),
              onPressed: () {},
            ),
            TextButton(
              child: Text("getDocumentPath"),
              onPressed: () {},
            ),
            TextButton(
              child: Text("保存文件"),
              onPressed: () {},
            ),
            TextButton(
              child: Text("获取文件"),
              onPressed: () {},
            ),
          ],
        ),
      ),
    );
  }
}

class UserBean {
  String? userName;
  int? userAge;

  UserBean.fromMap(dynamic map) {
    userName = map["name"] ?? "";
    userAge = map["age"] ?? 0;
  }
}
